import os


os.chdir(os.path.dirname(os.path.dirname(__file__)))
import ray


ray.init(address="auto")
# from trade.data.table_edit import remote_table_edit
from trade.data.table_edit import get_table_edit_obj


get_table_edit_obj()

# ray.get(remote_table_edit.init.remote())
from trade.data.add_factors import add_factor


# from trade.data.table_edit import remote_table_edit

if __name__ == "__main__":
    # add_factor("rvi14", "BTC/USDT", "2020-11-09", "2021-02-19", "1m")
    # add_batch_factors(
    #     ["kline"],  # "pascal14a",cfo14a_ohlc
    #     ["BTC/USDT"],
    #     datetime.fromisoformat("2025-02-11").timestamp() * 1000,
    #     datetime.fromisoformat("2025-02-25").timestamp() * 1000,
    #     "1m",
    #     n_jobs=4,
    #     max_part=2000,
    # )

    # end = int(time.time() * 1000)
    # start = end - 1000 * 60 * 60 * 24 * 365
    start = 1747800280000
    end = 1747804280000
    add_factor("kline", "ETH/USDT", start, end, "1m")
    # add_batch_factors_dag(
    #     ["kline"],
    #     [],
    #     ["ETH/USDT"],
    #     start,
    #     end,
    #     "1m",
    #     max_part=20000,
    #     n_jobs=2,
    #     callbacks=[],
    #     is_cover=True,
    # )
    # print(f"all state", ray.state)
    # print(f"all state", ray.state.list_tasks())
    # time.sleep(1000)
    # while not ray.state.():  # 伪代码
    #     time.sleep(1)
    # add_factor("kline", "BTC/USDT", start, end, "1m", callbacks=[write_factor_to_db])
    # add_factor("Pascal_14", "BTC/USDT", start, end, "1m", callbacks=[write_factor_to_db])
